from tensorboardX import SummaryWriter

if __name__ == '__main__':
    writer = SummaryWriter("log")
    for i in range(100):
        # 实际训练的时候，这里global_step可以设置为epoch（也就是 训练的轮数）
        writer.add_scalar("a", i, global_step=i)
        writer.add_scalar("b", i ** 2, global_step=i)

    writer.close()

    # 之后执行： tensorboard --logdir=log
